tywx.OpenDataContextUtil = {
    methodIndex: 0,
    methodCallDic: {},
    isOnTimer: !1,
    initCheckTimer: function() {
        if (null != this.getOpenDataContext() && !this.isOnTimer) {
            this.isOnTimer = !0;
            tywx.Timer.setTimer(cc.director, function() {
                tywx.OpenDataContextUtil.checkOpenDataContextStat();
            }, .1, cc.macro.REPEAT_FOREVER, 0);
        }
    },
    getOpenDataContext: function() {
        if (wx && wx.hasOwnProperty("getOpenDataContext")) {
            var t = wx.getOpenDataContext();
            if (t) return t;
        }
        return null;
    },
    checkOpenDataContextStat: function() {
        var t = this.getOpenDataContext();
        if (null == t) return null;
        var e = t.canvas.getContext("2d");
        for (var a in this.methodCallDic) tywx.LOGD("开始检查:" + a, "abcd"), e[a] ? (1 == e[a].status ? (tywx.LOGD("success_callback:" + a, JSON.stringify(e[a])), 
        this.methodCallDic[a].success_callback && this.methodCallDic[a].success_callback(e[a].data), 
        tywx.NotificationCenter.trigger(tywx.EventType.GET_OPEN_DATA_RESULT_SUCCESS, [ a, e[a].data ])) : (tywx.LOGD("success_callback:" + a, JSON.stringify(e[a])), 
        this.methodCallDic[a].fail_callback && this.methodCallDic[a].fail_callback(e[a].data), 
        tywx.NotificationCenter.trigger(tywx.EventType.GET_OPEN_DATA_RESULT_FAIL, [ a, e[a].data ])), 
        delete e[a], delete this.methodCallDic[a]) : new Date().valueOf() - this.methodCallDic[a].time > 2e3 && (tywx.NotificationCenter.trigger(tywx.EventType.GET_OPEN_DATA_RESULT_TIMEOUT, [ a ]), 
        delete e[a], delete this.methodCallDic[a]);
    },
    getUserInfo: function(t, e) {
        var a = "getUserInfo" + this.methodIndex, n = this.getOpenDataContext();
        return null == n ? null : (n.postMessage({
            method: "getUserInfo",
            data: {
                method_id: a
            }
        }), this.methodIndex++, this.methodCallDic[a] = {
            time: new Date().valueOf(),
            success_callback: t,
            fail_callback: e
        }, a);
    },
    updateRankData: function(t) {
        var e = "updateRankData" + this.methodIndex, a = [];
        for (var n in t) {
            var i = {
                key: n.toString(),
                value: t[n].toString()
            };
            a.push(i);
        }
        var l = this.getOpenDataContext();
        return null == l ? null : (l.postMessage({
            method: "updateRankData",
            data: {
                method_id: e,
                kvDataList: a
            }
        }), this.methodIndex++, e);
    },
    getFriendRankData: function(t, e, a) {
        var n = "getFriendRankData" + this.methodIndex, i = [ "avatarUrl", "nickName" ];
        for (var l in i) t.indexOf(i[l]) < 0 && t.push(i[l].toString());
        var s = this.getOpenDataContext();
        return null == s ? null : (s.postMessage({
            method: "getFriendRankData",
            data: {
                method_id: n,
                keyList: t
            }
        }), this.methodCallDic[n] = {
            time: new Date().valueOf(),
            success_callback: e,
            fail_callback: a
        }, n);
    },
    getGroupRankData: function(t, e, a, n) {
        var i = "getFriendRankData" + this.methodIndex, l = [ "avatarUrl", "nickName" ];
        for (var s in l) t.indexOf(l[s]) < 0 && t.push(l[s].toString());
        var c = this.getOpenDataContext();
        return null == c ? null : (c.postMessage({
            method: "getGroupRankData",
            data: {
                method_id: i,
                shareTicket: e,
                keyList: t
            }
        }), this.methodCallDic[i] = {
            time: new Date().valueOf(),
            success_callback: a,
            fail_callback: n
        }, i);
    }
};